from rest_framework import serializers
from apps.HttpTestcase.models import TestcaseReports


class ReportsSerializer(serializers.ModelSerializer):
    execute_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")
    testsuite_reports = serializers.SerializerMethodField()


    def get_testsuite_reports(self, obj):
        if obj.testsuite_reports is not None:
            result = obj.testsuite_reports.testsuite.name
            return result

    class Meta:
        model = TestcaseReports
        fields = '__all__'
